import { useStore } from "vuex"
import { IRootWithModel } from "@/types/userType"
export default function usePermission(
  pageName: string,
  handler: string,
): boolean {
  const store = useStore<IRootWithModel>()

  const intactPermission = `system:${(pageName == "User"
    ? "Users"
    : pageName
  ).toLocaleLowerCase()}:${handler}`
  const permission: string[] = store.state.login.perimssions
  const result = permission.some((item) => {
    return item == intactPermission
  })

  return result
}
